package com.appspot.niehonglei.action;

import javax.jdo.PersistenceManager;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.appspot.niehonglei.dao.PMF;
import com.appspot.niehonglei.jdo.Common;

public class DeleteCommon  implements ActionInterface {

	@Override
	public void execute(HttpServletRequest request, HttpServletResponse response) {
		String id = request.getParameter("id");
		String type = "0";
		try{
			if (id != null) {
				PersistenceManager pm = PMF.get().getPersistenceManager();
				Common common = pm.getObjectById(Common.class,Long.valueOf(id));
				type = common.getType() + "";
				pm.deletePersistent(common);
				pm.close();
				
			}
			response.sendRedirect("/common?new&type=" + type);
		}catch(Exception e){
			e.printStackTrace();
		}
	}

}
